package com.fr.chicken.controller;


import com.fr.chicken.annotation.Verification;
import com.fr.chicken.facade.base.BaseResponseDTO;
import com.fr.chicken.facade.request.*;
import com.fr.chicken.facade.response.FindFriendResponseDTO;
import com.fr.chicken.facade.response.GetFriendListResponseDTO;
import com.fr.chicken.service.FriendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/friend")
@Api(value = "/api-friend", description = "好友管理")
public class FriendController {

    @Autowired
    private FriendService friendService;

    @Verification
    @ApiOperation(value = "获取好友列表", notes = "获取好友列表")
    @RequestMapping(value = "/getFriendListInfo/{playerId}", method = RequestMethod.GET, produces = "application/json")
    public GetFriendListResponseDTO getFriendListInfo(@RequestHeader String accessToken, @PathVariable(value = "playerId") @ApiParam(required = true, value = "用户id") Long playerId) {
        GetFriendListResponseDTO response = friendService.getFriendList(playerId);
        return response;
    }

    @Verification
    @ApiOperation(value = "通过用户id查找好友", notes = "通过用户id查找好友")
    @RequestMapping(value = "/findFriendByPlayerId", method = RequestMethod.GET, produces = "application/json")
    public FindFriendResponseDTO findFriendByPlayerId(@RequestHeader String accessToken,FindFriendByPlayerIdRequsetDTO requset) {
        FindFriendResponseDTO response = friendService.findFriendByPlayerId(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "通过用户昵称查找好友", notes = "通过用户昵称查找好友")
    @RequestMapping(value = "/findFriendByNickName", method = RequestMethod.GET, produces = "application/json")
    public FindFriendResponseDTO findFriendByNickName(@RequestHeader String accessToken, FindFriendByNickNameRequsetDTO requset) {
        FindFriendResponseDTO response = friendService.findFriendByNickName(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "通过手机号码查找好友", notes = "通过手机号码查找好友")
    @RequestMapping(value = "/findFriendByPhoneNumber", method = RequestMethod.GET, produces = "application/json")
    public FindFriendResponseDTO findFriendByPhoneNumber(@RequestHeader String accessToken, FindFriendByPhoneRequsetDTO requset) {
        FindFriendResponseDTO response = friendService.findFriendByPhoneNumber(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "删除好友", notes = "删除好友")
    @RequestMapping(value = "/deleteFriend", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO deleteFriend(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) DeleteFriendRequsetDTO requset) {
        BaseResponseDTO response = friendService.deleteFriend(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "申请添加好友", notes = "申请添加好友")
    @RequestMapping(value = "/addFriend", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO addFriend(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) AddFriendRequsetDTO requset) {
        BaseResponseDTO response = friendService.addFriend(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "同意添加好友申请", notes = "同意添加好友申请")
    @RequestMapping(value = "/isAgreeAddFriend", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO isAgreeAddFriend(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) IsAgreeAddFriendRequsetDTO requset) {
        BaseResponseDTO response = friendService.isAgreeAddFriend(requset);
        return response;
    }

    @Verification
    @ApiOperation(value = "赠送好友鸡蛋", notes = "赠送好友鸡蛋")
    @RequestMapping(value = "/giveFriendEgg", method = RequestMethod.POST, produces = "application/json")
    public BaseResponseDTO giveFriendEgg(@RequestHeader String accessToken, @RequestBody @ApiParam(name = "json对象", value = "传入json格式", required = true) GiveFriendEggRequsetDTO requset) {
        BaseResponseDTO response = friendService.giveFriendEgg(requset);
        return response;
    }
}
